package AtCoderBeginnerContest353;

import java.util.Arrays;
import java.util.Scanner;

public class C {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long mod = (long) 1e8;
		long ret = 0;
		long[] a = new long[n + 10];
		long[] sum = new long[n + 10];
		
		//就是二分
		for(int i = 1; i <= n; i ++ ) {
			a[i] = sc.nextLong();
			// 也是要利用前缀和的思想
			sum[i] = sum[i - 1];
			sum[i] += a[i];
		}
		for(int i = 1; i <= n; i ++ ) {
			ret += (n - i) * a[i] + (sum[n] - sum[i]);
		}
	//	System.out.println("ret = " + ret); // ret出现了问题
		
		Arrays.sort(a, 1, n + 1);
//		for(int i = 1; i <= n; i ++ ) {
//			System.out.print(a[i] + " ");
//		}
		for(int i = 1; i <= n; i ++ ) {
			int l = i, r = n + 1;
			long x = mod - a[i]; // 这个是要找的 找到第一个大于等于x的位置
			while(l + 1 < r) {
				int mid = l + r >> 1;
				if(a[mid] < x)l = mid;
				else r = mid;
			}
			//System.out.println("i = " + i + " l = " + l);
			// l + 1 是最后的答案
			ret -= (mod * (n - l));
		}
		System.out.print(ret);
	}
}
